using UnityEngine;

namespace DA.AnimGraph {
    internal struct ClipLink {
        public float duration { get; private set; }

        private readonly AUID uuid;

        public ClipLink(ClipLinkDesc desc) {
            uuid = desc.uuid;
            duration = -1;
        }

        internal AnimationClip Get(in BuildContext context) {
            if (context.resourcesMap.TryGetValue(uuid, out Object obj)) {
                if (obj is AnimationClip clip) {
                    duration = clip.length;
                    return clip;
                }
            }
            return null;
        }
    }
}
